from fastapi import FastAPI
import uvicorn
from config.settings import Settings
from database.database import Base, engine
from utils.authMiddleware import AuthMiddleware
from utils.exceptions import add_exception_handlers
from utils.log import logger
from utils.web import load_routers

Base.metadata.create_all(bind=engine)
app = FastAPI(root_path="/api/v1")
# add config/settings
settings = Settings()
# add routers
load_routers(app, routers_dir='routers')
# add middleware
app.add_middleware(AuthMiddleware)
# add add_exception_handlers
add_exception_handlers(app)

logger.info("starting app..")

if __name__ == "__main__":
    uvicorn.run(app, host="0.0.0.0", port=8000)